<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义JS对象</title>
</head>
<body>
    <script>
        //自定义一个自带属性和方法的对象
        let p1 ={
            name:"李四",
            age:18,
            eat:function () {
                console.log(this.name+'~~~'+this.age);
            }
        };
        console.log(p1);
        p1.eat();

        //2.定义一个空对象,再动态的添加属性与方法
        let p2 ={};
        p2.name='王五';
        p2.age=30;
        p2.eat=function () {
            console.log(this.name+'~~~'+this.age);
        };
        console.log(p2);
        p2.eat();


    </script>
</body>
</html>